#1.命名关键字参数(了解):在定义函数时，*后定义的参数，如下所示
def fun(x,y,*,a,b):#x,y为位置参数，a,b为命名关键字参数
    print(x,y)
    print(a,b)
#fun(1,2,22,33)#TypeError: fun() takes 2 positional arguments but 4 were given
#fun(1,2)#TypeError: fun() missing 2 required keyword-only arguments: 'a' and 'b'
fun(1,2,a=22,b=33)#1 2#22 33
#位置形参必须在默认形参左边如 def func(y=3,x): 就是错误的SyntaxError: non-default argument follows default argument
def func(x,y=3):
    print(x,y)
func(1,2)
#默认函数的值是在函数定义阶段被赋值的,准确地说被赋予的是值的内存地址
#例一
m=2
print('id2',id(m))
def func1(x,y=m):
    print(x,y)
m=3333333
print('id1:',id(m))
func1(1)
#例二
m=[11111,]
print('m1:',m,id(m))
def func2(x,y=m):#y->(指向)[11111,]的内存地址
    print('m2:',m,id(m))
    print(x,y)
print('m3:',m,id(m))
m.append(333333)
print('m4:',m,id(m))
func2(1)
print(m,id(m))
def func3(x,y,z,l=[]):
    l.append(x)
    l.append(y)
    l.append(z)
    print(l)
func3(1,2,3)
new_l=[111,222]
func3(1,2,3,new_l)
def func4(x,y,z,l=None):
    if l is None:
        l=[]
    l.append(x)
    l.append(y)
    l.append(z)
    print(l)
func4(1,2,3)
